<template>
    <div id="CompanyIntroduction">
      <section class="page-banner">
        <div class="image-layer"></div>

        <div class="banner-inner">
          <div class="auto-container">
            <div class="inner-container clearfix">
            </div>
          </div>
        </div>
      </section>
      <div class="breadcrumb">
        <el-breadcrumb separator="/" class="router-row">
          <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item><a href="/">成果列表</a></el-breadcrumb-item>
        </el-breadcrumb>
      </div>
      <div class="search-box">
        <div class="box-left">
          <el-form :model="ruleForm" :inline="true" ref="ruleForm" label-width="60px" class="demo-ruleForm">
            <el-form-item label="主题：">
              <el-input v-model="ruleForm.keyword" style="max-width: 160px"></el-input>
            </el-form-item>
            <el-form-item label="日期：" prop="value1">
              <el-date-picker
                v-model="ruleForm.value1"
                type="daterange"
                size="small"
                range-separator="至"
                value-format='yyyy-MM-dd'
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                @change="startEndValValChange()">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="机构：" prop="publisher">
              <el-select v-model="ruleForm.publisher" placeholder="请选择类型" style="width: 150px">
                <el-option v-for="(item, index) in publisherList"
                           :key="index"
                           :label="item.publisher"
                           :value="item.publisher"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="类型：" prop="articleClass">
              <el-select v-model="ruleForm.articleClass" placeholder="请选择类型" style="width: 150px">
                <el-option v-for="(item, index) in typeList"
                           :key="index"
                           :label="item.publisher"
                           :value="item.publisher"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button class="confirm" type="primary" @click="submit('ruleForm')">筛选</el-button>
              <el-button @click="resetForm('ruleForm')">清空</el-button>
            </el-form-item>
          </el-form>
        </div>
        <div class="list-box">
          <div class="box-row" v-for="(item, idx) in listData" :key="idx">
            <div class="item-date">
              <div class="date">
                <span class="day">{{ item.publishFormatTime.slice(item.publishFormatTime.length - 2) }}</span>
                <span class="month">{{ initDate(item) }}</span>
              </div>
            </div>
            <div class="list-item">
              <div class="tags">{{ item.articleType }}</div>
              <div class="titile">{{ item.publisher }}</div>
              <div class="content">{{ item.titleOrg}}</div>
              <div class="goDetail" @click="navClick(item)">查看详情<i style="margin-left: 8px" class="el-icon-right"></i></div>
            </div>
          </div>
<!--          <el-pagination-->
<!--            background-->
<!--            layout="prev, pager, next"-->
<!--            :total="1000">-->
<!--          </el-pagination>-->

        </div>
      </div>
    </div>
</template>
<script>
import {connectUs, getAgencyType, getAllOrientedData, getByLabelName, getList} from "../api/api";
export default {
    name: 'Technologyintroduction',
    data(){
        return{
          listData: [],
          publisherList: [],
          typeList: [],
          ruleForm: {
            value1: [],
            keyword: '',
            articleClass: '',
            publisher: '',
            date1: '',
            date2: '',
            delivery: false,
            type: [],
            resource: '',
            desc: ''
          },
        }
    },
    methods: {
      startEndValValChange() {
        if (this.ruleForm.value1.length > 0) {
          this.ruleForm.startTime = this.ruleForm.value1[0];
          this.ruleForm.endTime = this.ruleForm.value1[1];
        } else {
          this.ruleForm.startTime = "";
          this.ruleForm.endTime = "";
        }
      },
      initDate(item){
        let time = item.publishFormatTime.slice(5,7)
        switch (time) {
          case '01':
            return 'JANUARY'
          case '02':
            return 'FEBRUARY'
          case '03':
            return 'MARCH'
          case '04':
            return 'APRIL'
          case '05':
            return 'MAY'
          case '06':
            return 'JUNE'
          case '07':
            return 'JULY'
          case '08':
            return 'AUGUST'
          case '09':
            return 'SEPTEMBER'
          case '10':
            return 'OCTOBER'
          case '11':
            return 'NOVEMBER'
          case '12':
            return 'DECEMBER'
        }
      },
      navClick(item) {
        this.$router.push({
          name: 'prodDetail',
          query: {
            id: item.id
          }
        })
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
        this.ruleForm.startTime = []
        this.ruleForm.endTime = []
        this.ruleForm.keyword = ''
      },
      submit() {
        this.$refs.ruleForm.validate(valid => {
          if (valid) {
            let data = {
              startTime: this.ruleForm.startTime,
              endTime: this.ruleForm.endTime,
              keyword: this.ruleForm.keyword,
              publisher: this.ruleForm.publisher,
              articleClass: this.ruleForm.articleClass
            }
            getList(data).then( res => {
              console.log(res.data)
              if (res.data.code == 200) {
                this.$message.success('提交成功')
                this.listData = res.data.rows
              }else {
                this.$message.error(res.data.msg)
              }
            }).catch(err => {
              console.log(err)
            })
          }
        })

      }
    },
    mounted(){
      console.log('this.$route.query', this.$route.query)
      if (this.$route.query.id) {
        getAllOrientedData({
          orientedId: this.$route.query.id
        }).then(res => {
          this.listData = res.data.rows
        }).catch(err => {
          console.log(err)
        })
      } else if (this.$route.query.name) {
        getByLabelName({
          labelName: this.$route.query.name
        }).then(res => {
          this.listData = res.data.rows
        }).catch(err => {
          console.log(err)
        })
      } else {
        getList().then(res => {
          console.log('res', res.data.rows)
          this.listData = res.data.rows
        }).catch(err => {
          console.log(err)
        })
      }
      getAgencyType({
        givenField: 'publisher' // 机构
      }).then(res => {
        this.publisherList = res.data.data
      }).catch(err => {
        console.log(err)
      })
      getAgencyType({
        givenField: 'article_class' // 类型
      }).then(res => {
        // this.typeList = res.data
      }).catch(err => {
        console.log(err)
      })
    }
}
</script>
<style scoped>
/deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: #1363c6!important
}
/deep/ .el-pagination.is-background .el-pager li:hover {
  color: #1363c6!important
}
.box-row {
  position: relative;
  display: block;
  padding: 30px 0px;
}
.goDetail {
  cursor: pointer;
  position: absolute;
  top: 25px;
  right: 20px;
  height: 80px;
  padding-top: 45px;
  width: 150px;
  display: block;
  text-align: center;
  border-left: 1px solid rgba(0, 0, 0, 0.10);
}
.goDetail:hover {
  color: #1363c6;
}
.content {
  width: 75%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.titile {
  color: #222222;
  font-weight: 700;
  line-height: 1.25em;
  margin: 0 0 5px;
}
.tags {
  width: max-content;
  position: relative;
  display: inline-block;
  font-size: 13px;
  text-transform: capitalize;
  line-height: 20px;
  color: #ffffff;
  background: #1363c6;
  padding: 3px 10px;
  border-radius: 13px;
  margin-bottom: 20px;
}
.item-date:before {
  content: '';
  position: absolute;
  left: 50px;
  top: 15px;
  height: 100%;
  border-left: 1px solid rgba(0, 0, 0, 0.10);
}
* {
  box-sizing: unset!important;
}
.item-date {
  position: absolute;
  left: 20px;
  top: 15px;
  width: 101px;
  height: 160px;
  color: #222222;
  text-align: center;
  font-family: 'Manjari', sans-serif;
}
.date {
  position: absolute;
  left: 0;
  top: 50%;
  margin-top: -50px;
  width: 100px;
  height: 100px;
  font-size: 30px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.10);
  z-index: 3;
  -webkit-transition: all 300ms ease;
  -moz-transition: all 300ms ease;
  -ms-transition: all 300ms ease;
  -o-transition: all 300ms ease;
  transition: all 300ms ease;
}
.day {
  position: relative;
  display: block;
  line-height: 30px;
  padding-top: 25px;
}
.month {
  position: relative;
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  color: #757575;
  line-height: 20px;
}
.list-item {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 165px;
  min-height: 135px;
  padding-top: 25px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.10);
}
.list-item:hover {
  box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.07);
  border-bottom: 1px solid rgba(0, 0, 0, 0);
}
.box-row:before {
  content: '';
  position: absolute;
  right: -30px;
  top: -2px;
  left: -30px;
  bottom: -1px;
  display: block;
  background: #ffffff;
  opacity: 0;
  -webkit-transition: all 300ms ease;
  -moz-transition: all 300ms ease;
  -ms-transition: all 300ms ease;
  -o-transition: all 300ms ease;
  transition: all 300ms ease;
}
.box-row:after {
  content: '';
  position: absolute;
  left: 140px;
  right: 0;
  bottom: 0px;
  display: block;
  -webkit-transition: all 300ms ease;
  -moz-transition: all 300ms ease;
  -ms-transition: all 300ms ease;
  -o-transition: all 300ms ease;
  transition: all 300ms ease;
}
.list-box {
  display: flex;
  flex-direction: column;
}
.confirm {
  .el-button--primary {
    background-color: #1363c6;
    border-color: #1363c6;
  }
}
.demo-ruleForm {
  padding-top: 25px;
  box-shadow: 0px 0px 25px 0px rgba(0, 0, 0, 0.10);
  padding-left: 10px;
}
.router-row {
  width: 1320px;
  margin: 0 auto;
  line-height: 38px;
}
.breadcrumb {
  margin: 10px 0;
  color: #858d8f;
  background-color: #f5f6f8;
  line-height: 38px;
  font-size: 13px;
}
.type-select {
  position: relative;
  //line-height: 56px;
  //padding: 12px 50px 12px 20px;
  //border: 1px solid #d0d0d0;
  background: #ffffff;
  color: #061138;
  display: block;
  font-size: 14px;
  width: 100%;
  //height: 56px;
  border-radius: 2px;
  transition: all 500ms ease;
  -moz-transition: all 500ms ease;
  -webkit-transition: all 500ms ease;
  -ms-transition: all 500ms ease;
  -o-transition: all 500ms ease;
  box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.07);
  font-weight: 500;
}
.box-left {
  width: 100%;
  padding: 30px 0 ;
}
.search-box {
  width: 100%;
  max-width: 1320px;
  display: flex;
  flex-direction: row;
  margin: 0 auto;
  padding-top: 30px;
  display: flex;
  flex-direction: column;
}
.cooperation{
  width: 100%;
  height: 520px;
}
.page-banner {
  margin-top: 69px;
  position: relative;
  padding: 0;
  color: #ffffff;
}

.page-banner .image-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-image:url(../assets/img/main-slider/banner-image-5.jpg);
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
}

.page-banner .image-layer:before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.40);
}

.page-banner .banner-inner {
  position: relative;
  display: block;
  text-align: center;
  z-index: 2;
}

.page-banner .inner-container {
  position: relative;
  padding: 140px 0px;
}

.page-banner h1 {
  position: relative;
  font-size: 48px;
  color: #ffffff;
  line-height: 1.2em;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: capitalize;
  margin: 0;
}

.page-banner .page-nav {
  position: absolute;
  left: 0;
  bottom: 0;
  padding-bottom: 15px;
  text-align: left;
  font-weight: 700;
  font-family: 'Manjari', sans-serif;
}

.page-banner .bread-crumb {
  position: relative;
  display: inline-block;
}

.page-banner .bread-crumb li {
  position: relative;
  float: left;
  font-size: 13px;
  line-height: 24px;
  color: #bababa;
  font-weight: 700;
  text-transform: uppercase;
  cursor: default;
  padding-right: 15px;
  margin-right: 15px;
}

.page-banner .bread-crumb li:before {
  position: absolute;
  right: -15px;
  width: 30px;
  text-align: center;
  font-size: 10px;
  line-height: 24px;
  color: #bababa;
  font-weight: 400;
  content: "_";
}

.page-banner .bread-crumb li:last-child {
  padding-right: 0;
  margin-right: 0;
}

.page-banner .bread-crumb li:last-child:before {
  display: none;
}

.page-banner .bread-crumb li a {
  color: #bababa;
  font-weight: 500;
  -webkit-transition: all 300ms ease;
  -moz-transition: all 300ms ease;
  -ms-transition: all 300ms ease;
  -o-transition: all 300ms ease;
  transition: all 300ms ease;
}

.page-banner .bread-crumb li a:hover,
.page-banner .bread-crumb li.active {
  color: #ffffff;
}
</style>

